<?php
/* @var $this ReviewsController */
/* @var $model Reviews */
?>

<?php
$this->breadcrumbs = array(
	'Reviews' => array('index'),
	$model->reviewId,
);
?>

<div class="row-fluid">
    <div class="span12">
        <div class="grid simple">
			<div class="grid-title no-border">
				<br />
			</div>
			<div class="grid-body no-border">
				<?php
				$this->widget('zii.widgets.CDetailView', array(
					'htmlOptions' => array(
						'class' => 'table table-striped table-condensed table-hover',
					),
					'data' => $model,
					'attributes' => array(
						'reviewId',
						'reviewContent',
						'reviewUsername',
						'reviewUseremail',
						'reviewUserphone',
						'reviewUserIp',
						'reviewOrderNo',
						'reviewDate',
						'reviewActive',
					),
				));
				$colors = array('success', 'info', 'warning', 'danger', 'success', 'info', 'warning', 'danger', 'success', 'info', 'warning', 'danger','success', 'info', 'warning', 'danger', 'success', 'info', 'warning', 'danger', 'success', 'info', 'warning', 'danger','success', 'info', 'warning', 'danger', 'success', 'info', 'warning', 'danger', 'success', 'info', 'warning', 'danger');
				?>
				<?php $sql = "SELECT \"ratingId\", \"ratingSum\" FROM {{_rev2rate}} WHERE \"reviewId\" = '$model->reviewId'"; ?>
				<?php $ratings = Yii::app()->db->getCommandBuilder()->createSqlCommand($sql)->queryAll(); ?>
				<?php foreach ($ratings as $key=>$rating): ?>
				<?php $type = Ratingtype::model()->findByPk((int)$rating['ratingId']); echo $type['ratingTitle']; $percent = ((int)$rating['ratingSum'])/((int)$type['ratingMax']) * 100; ?>
					<div class="progress progress-<?php echo $colors[$key]; ?>">
						<div class="bar" style="width: <?php echo $percent; ?>%;" data-percentage="0%"></div>
					</div>
				<?php endforeach; ?>
			</div>
        </div>	
    </div>
</div>